#include <stdio.h>
#include <math.h>
#include "csi_math.h"

#define STATIS_SIZE 128

static q15_t src[STATIS_SIZE] = {
    0x0af7, 0x2217, 0xd65a, 0x0066, 0xf0fb, 0x3d15, 0x37d2, 0x3245,
    0xf8c6, 0x2032, 0x3467, 0xefc9, 0xcee3, 0x0337, 0xebaa, 0x2cb9,
    0xd7d6, 0xdab8, 0x03e5, 0xcaca, 0xded2, 0x1139, 0xce38, 0x0dbd,
    0x31e4, 0xfecf, 0xe821, 0x218e, 0x3a2e, 0x12ac, 0xfe1f, 0xf816,
    0xd7db, 0xf8b9, 0xfe7b, 0x2e3a, 0x1bb5, 0x0f67, 0xcb7e, 0xce4e,
    0x09ad, 0xfb18, 0x05d1, 0xc4de, 0x0a26, 0x1082, 0xfdb0, 0xd48c,
    0x208f, 0x2591, 0xe54c, 0x00f9, 0xde77, 0xd8aa, 0x2783, 0xc889,
    0xd912, 0x3cc6, 0x099d, 0x0aa7, 0x399a, 0xccce, 0x307a, 0x321b,
    0xdb66, 0xd55f, 0x12b4, 0xd715, 0xceeb, 0xeec3, 0xf381, 0xcb7f,
    0x1786, 0x0601, 0x3e34, 0xdb3b, 0x35a1, 0x1524, 0x1f2a, 0xf071,
    0xfcc5, 0xcd9a, 0x3120, 0xf8f9, 0x1589, 0x1d36, 0xe490, 0x0bfe,
    0xef6e, 0x25d7, 0xc96a, 0x3f12, 0x2355, 0xc0f2, 0x31c9, 0x2e9c,
    0x194b, 0x3147, 0xfb9a, 0xef8f, 0xcaa0, 0x3fa5, 0x2f57, 0xc002,
    0x1709, 0x13d3, 0xf4b6, 0xfcfa, 0xf1b3, 0xf9dd, 0xc36d, 0xf670,
    0xcd8b, 0xc585, 0x072f, 0x0e3f, 0x1e92, 0xe0e3, 0x1cf6, 0x1b4c,
    0x007b, 0x3246, 0x23c3, 0xff58, 0x2179, 0x1562, 0x3d33, 0xcefc
};

int main()
{
    q15_t result;
    q15_t ref_result = 0xa8b;
    csi_var_q15(src, STATIS_SIZE, &result);

    if (result == ref_result) {
        printf("Example run successfully!\r\n");
    } else {
        printf("Example run failed!\r\n");
    }

    return 0;
}
